package com.mars.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 1、获取前端参数
        if(req.getParameter("method").equals("login")){
            System.out.print("name: " + req.getParameter("username"));
            System.out.println(" pwd: ");
            System.out.print(req.getParameter("password"));
        }

        // 2、调用业务层

        // 3、视图转发or重定向
        req.getRequestDispatcher("/jsp/hello.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
